#include "queue_worker.h"
#include <boost/bind.hpp>
#include "gen_empty.h"
//#include <boost/lambda.hpp>
using namespace boost;

void queue_worker::run()
{
	while(1) {
		if(is_interrupted()) {
			return;
		}
		boost::shared_ptr<message> m(_queue->get());
		boost::mutex::scoped_lock l(mtx);
		if(m->type() == message::PAUSE) {
			pause();
		} else if(m->type() == message::PLAY) {
			boost::shared_ptr<play_message> msg(
				boost::dynamic_pointer_cast<play_message>(
					m));
			play(msg->get_title().get());
		}
	}
}

void queue_worker::start()
{
	_thrd.reset(new boost::thread(bind(&queue_worker::run, this)));
}

